import React from 'react'
import { CalendarPicker } from 'antd-mobile'
import dayjs from 'dayjs'
import { citySetDate } from '../../../reducers/citySlice'
import { useDispatch } from 'react-redux'


function DatePopup({visible1, setVisible1}) {
    const dispatch = useDispatch()
    return (
        <CalendarPicker
            visible={visible1}
            selectionMode='single'
            onClose={() => setVisible1(false)}
            onMaskClick={() => setVisible1(false)}
            min={new Date()} 
            max={dayjs().add(14,'day').valueOf()} 
            onConfirm={(value) => {
                const nDate = dayjs(value).format('YYYY-MM-DD')
                dispatch(citySetDate(nDate))
            }}
        />
  )
}

export default DatePopup
